
//验证码
$('#sc').html(setVC()).click(function(){$(this).html(setVC())});
$('[name="reset]').click(function(){$(this).html(setVC())});


//button
$('button').click(function(){
let name=$('[name="name"]').val();
let pwd1 = $('[name="pwd1"]').val();
let pwd2 = $('[name="pwd2"]').val();
let vc1 = $('[name="vc"]').val();
let vc2 = $('#sc').html();


//验证码
if(pwd1 !== pwd2){
$('[name="pwdSpan"]').html('您输入的两个密码 不相同');
return ;
}else{
$('[name="pwdSpan"]').html('');
}

//不区分大小写
if(vc1.toLowerCase() !== vc2.toLowerCase()){
$('[name="vcSpan"]').html('您输入的验证码有误');
$('#sc').html(setVC());
return ;
}else{
$('[name="vcSpan"]').html('');
}

$('#sc').html(setVC());

//发送ajax
const xhr = myPromiseJQueryAjax('../server/goods_reg.php' , 'post',   {userName:name,userPwd:pwd1 },'json');
xhr.then(function(res){
if(res.result ===0){
window.alert('您的注册失败,账号重复了');
}else if(res.result === 1){
let time=3;
$('[name="msg"]').html(`恭喜您注册成功,${time}秒后跳转登录页面`);

setInterval(function(){
    time--;

    if (time===0){
        window.location.href='./login.html';
        return;
    }
    $('[name="msg"]').html(`恭喜您注册成功,${time}秒后跳转登录页面`);
},1000)
}
})

})  
